from django.db import models

class Area(models.Model):
    name = models.CharField(max_length=50, verbose_name='名称')
    parent = models.ForeignKey('self', related_name='subs', on_delete=models.SET_NULL, null=True, blank=True, verbose_name='上级地区名称')

    class Meta:
        db_table = 'tb_areas'
        verbose_name = '行政区划'
        verbose_name_plural = '行政区划'


    def __str__(self):
        return self.name

    # area = Area.objects.get(id=id)
    # area.area_set.all()
    # 使用subs
    # area.subs.all()